//index.js
//获取应用实例
const app = getApp();
var WxParse = require('../../static/wxParse/wxParse.js');
Page({
  data: {
    userInfo: {},
    imgUrls: [
        {
            "id":1,
            "title":"banner1",
            "img_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1530806900213&di=9c70bc5cdfa7240c100a55d9276bca64&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F01c6d8577270370000012e7e30d877.jpg%401280w_1l_2o_100sh.jpg"
        },
        {
            "id":2,
            "title":"banner1",
            "img_url":"https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1196738664,891423724&fm=173&app=25&f=JPEG?w=218&h=146&s=A1FA7D8648628E966605E46303006053"
        },
        {
            "id":3,
            "title":"banner1",
            "img_url":"https://ss2.baidu.com/6ONYsjip0QIZ8tyhnq/it/u=3255538847,4086770196&fm=173&app=25&f=JPEG?w=218&h=146&s=6857149C46285EBA8388D8C70300A0A0"
        }
    ],
      title: "【与里弗君一起晨读】重塑语音，解放听力",
      created_at: "2018-07-05 12:09:00",
      daka_count: "702",
      daka_user_list:[
          {
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },{
              "id":"1",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          },
          {
              "id":"2",
              "photo_url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531408684&di=fdfe56cd90af0405a046a6e0a4b7ad81&imgtype=jpg&er=1&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201503%2F22%2F20150322100452_ezcWW.jpeg",
              "nickname":"简茴"
          }
      ],
      content:'<p style="color:red">这里是活动详情的内容</p>',
      has_clock:"0"
  },
  toHome: function () {
      wx.switchTab({
          url: '../index/index'
      })
  },
   toDiscuss: function () {
        wx.navigateTo({
            url: '../discuss/discuss'
        })
    },
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
    WxParse.wxParse('article', 'html', this.data.content, this, 5);
  },
  getUserInfo: function(e) {
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
